//
//  UIButton+Corners.m
//  SegmentCornerView
//
//  Created by 宋飞龙 on 16/4/12.
//  Copyright © 2016年 宋飞龙. All rights reserved.
//

#import "UIButton+Corners.h"

@implementation UIButton (Corners)

- (UIView *)setCornerView:(int)i titleFrame:(CGRect)titleFrame cornerFrame:(CGRect)cornerFrame text:(NSString *)text buttonTitieX:(CGFloat)buttonTitieX{
    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(lroundf(buttonTitieX), 5, cornerFrame.size.width>14.0f ? ceilf(cornerFrame.size.width):14.0f, 14.0f)];
    if ([text isEqualToString:@"0"] || text.length == 0) {
        label.hidden = YES;
    } else {
        label.hidden = NO;
    }
    label.text = text;
    label.textColor = [UIColor whiteColor];
    label.backgroundColor = [UIColor redColor];
    label.layer.masksToBounds = YES;
    label.layer.cornerRadius = 7.0f;
    label.tag = i + 10;
    label.textAlignment = NSTextAlignmentCenter;
    label.font = [UIFont systemFontOfSize:10.0f];
    return label;
}

@end
